<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::Transactions</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::Transactions</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/activerecord/lib/active_record/transactions_rb.html">
                vendor/rails/activerecord/lib/active_record/transactions.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
See <a
href="Transactions/ClassMethods.html">ActiveRecord::Transactions::ClassMethods</a>
for documentation.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001336">included</a>&nbsp;&nbsp;
      <a href="#M001338">rollback_active_record_state!</a>&nbsp;&nbsp;
      <a href="#M001337">transaction</a>&nbsp;&nbsp;
      <a href="#M001339">with_transaction_returning_status</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Transactions/ClassMethods.html" class="link">ActiveRecord::Transactions::ClassMethods</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001336" class="method-detail">
        <a name="M001336"></a>

        <div class="method-heading">
          <a href="#M001336" class="method-signature">
          <span class="method-name">included</span><span class="method-args">(base)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001336-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001336-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/transactions.rb, line 9</span>
 9:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>(<span class="ruby-identifier">base</span>)
10:       <span class="ruby-identifier">base</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-constant">ClassMethods</span>)
11: 
12:       <span class="ruby-identifier">base</span>.<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
13:         [<span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:save</span>, <span class="ruby-identifier">:save!</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
14:           <span class="ruby-identifier">alias_method_chain</span> <span class="ruby-identifier">method</span>, <span class="ruby-identifier">:transactions</span>
15:         <span class="ruby-keyword kw">end</span>
16:       <span class="ruby-keyword kw">end</span>
17:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001338" class="method-detail">
        <a name="M001338"></a>

        <div class="method-heading">
          <a href="#M001338" class="method-signature">
          <span class="method-name">rollback_active_record_state!</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Reset id and @new_record if the <a
href="Transactions.html#M001337">transaction</a> rolls back.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001338-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001338-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/transactions.rb, line 154</span>
154:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rollback_active_record_state!</span>
155:       <span class="ruby-identifier">id_present</span> = <span class="ruby-identifier">has_attribute?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">primary_key</span>)
156:       <span class="ruby-identifier">previous_id</span> = <span class="ruby-identifier">id</span>
157:       <span class="ruby-identifier">previous_new_record</span> = <span class="ruby-identifier">new_record?</span>
158:       <span class="ruby-keyword kw">yield</span>
159:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
160:       <span class="ruby-ivar">@new_record</span> = <span class="ruby-identifier">previous_new_record</span>
161:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">id_present</span>
162:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">id</span> = <span class="ruby-identifier">previous_id</span>
163:       <span class="ruby-keyword kw">else</span>
164:         <span class="ruby-ivar">@attributes</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">primary_key</span>)
165:         <span class="ruby-ivar">@attributes_cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">primary_key</span>)
166:       <span class="ruby-keyword kw">end</span>
167:       <span class="ruby-identifier">raise</span>
168:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001337" class="method-detail">
        <a name="M001337"></a>

        <div class="method-heading">
          <a href="#M001337" class="method-signature">
          <span class="method-name">transaction</span><span class="method-args">(&amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
See <a
href="Transactions/ClassMethods.html">ActiveRecord::Transactions::ClassMethods</a>
for detailed documentation.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001337-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001337-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/transactions.rb, line 137</span>
137:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transaction</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
138:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">transaction</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
139:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001339" class="method-detail">
        <a name="M001339"></a>

        <div class="method-heading">
          <a href="#M001339" class="method-signature">
          <span class="method-name">with_transaction_returning_status</span><span class="method-args">(method, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes <tt>method</tt> within a <a
href="Transactions.html#M001337">transaction</a> and captures its return
value as a status flag. If the status is true the <a
href="Transactions.html#M001337">transaction</a> is committed, otherwise a
ROLLBACK is issued. In any case the status flag is returned.
</p>
<p>
This method is available within the context of an <a
href="Base.html">ActiveRecord::Base</a> instance.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001339-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001339-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/transactions.rb, line 176</span>
176:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_transaction_returning_status</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
177:       <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>
178:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">transaction</span> <span class="ruby-keyword kw">do</span>
179:         <span class="ruby-identifier">status</span> = <span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
180:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Rollback</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">status</span>
181:       <span class="ruby-keyword kw">end</span>
182:       <span class="ruby-identifier">status</span>
183:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>